import db from "../models/index.js";

let userChatList = db.user_chat_list;
let userChatListDao = {};
//查找用户的聊天列表篇
userChatListDao.getUserChatList = (_account) => {
  return userChatList.findAndCountAll({
    where: {
      _account
    },
    raw: true,
  });
};
//增加用户的聊天列表
userChatListDao.addUserChat = (_account, _session_id, t) => {
  if (!t) {
    return userChatList.create({_account, _session_id});
  }
  return userChatList.create({_account, _session_id}, {transaction: t});
};
//删除用胡的某个聊天列表
userChatListDao.deleteUserChat = (_account, _session_id, t) => {
  if (!t) {
    return userChatList.destroy({where: {_account, _session_id}});
  }
  return userChatList.destroy({where: {_account, _session_id}, transaction: t});
};
export default userChatListDao;
